<?php

namespace App\Http\Controllers;

use App\Models\CollPlace;
use App\Models\ShippingAddress1;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;


class ShippingAddress1Controller extends Controller
{

    // 用户下单
    public function add(Request $request)
    {
        $data = $request->input();
        if (!$data['mobile']) {
            return response()->json(['status' => 0, 'msg' => '必须输入手机号码']);
        }
        if (!$data['area']) {
            return response()->json(['status' => 0, 'msg' => '必须选择区域']);
        }
        if (!$data['address']) {
            return response()->json(['status' => 0, 'msg' => '必须输入详细地址']);
        }
        if (!$data['realname']) {
            return response()->json(['status' => 0, 'msg' => '必须输入真实姓名']);
        }
        $ret = ShippingAddress1::create($data);
        if ($ret->id) {
            return response()->json(['status' => 1, 'msg' => '下单成功']);
        } else {
            return response()->json(['status' => 0, 'msg' => '下单失败']);
        }
    }
}
